%macro ISR_WITHOUTERRORCODE 1
  [global isr_%1]
  isr_%1:
    cli                         ; Disable interrupts firstly.
    push byte 0                 ; Push a dummy error code.
    push byte %1                ; Push the interrupt number.
    jmp isr_common_stub         ; Go to our common handler code.
%endmacro

%macro ISR_WITHERRORCODE 1
  [global isr_%1]
  isr_%1:
    cli                         ; Disable interrupts.
    push byte %1                ; Push the interrupt number
    jmp isr_common_stub
%endmacro

ISR_WITHOUTERRORCODE 0
ISR_WITHOUTERRORCODE 1
ISR_WITHOUTERRORCODE 2
ISR_WITHOUTERRORCODE 3
ISR_WITHOUTERRORCODE 4
ISR_WITHOUTERRORCODE 5
ISR_WITHOUTERRORCODE 6
ISR_WITHOUTERRORCODE 7
ISR_WITHOUTERRORCODE 9
ISR_WITHOUTERRORCODE 15
ISR_WITHOUTERRORCODE 16
ISR_WITHOUTERRORCODE 17
ISR_WITHOUTERRORCODE 18
ISR_WITHOUTERRORCODE 19
ISR_WITHOUTERRORCODE 20
ISR_WITHOUTERRORCODE 21
ISR_WITHOUTERRORCODE 22
ISR_WITHOUTERRORCODE 23
ISR_WITHOUTERRORCODE 24
ISR_WITHOUTERRORCODE 25
ISR_WITHOUTERRORCODE 26
ISR_WITHOUTERRORCODE 27
ISR_WITHOUTERRORCODE 28
ISR_WITHOUTERRORCODE 29
ISR_WITHOUTERRORCODE 30
ISR_WITHOUTERRORCODE 31
ISR_WITHERRORCODE 8
ISR_WITHERRORCODE 10
ISR_WITHERRORCODE 11
ISR_WITHERRORCODE 12
ISR_WITHERRORCODE 13
ISR_WITHERRORCODE 14

[extern isr_handler]
isr_common_stub:
	pushad
	push ds
    push es
	push fs
	push gs
	mov ax, 0x10
	mov ds, ax
	mov es, ax
	mov fs, ax
	mov gs, ax
	call isr_handler
	pop gs
	pop fs
	pop es
	pop ds
	popad
	add esp, 8;
	sti
	iret
